using Godot;
using System;

public partial class BTFightSequence : BTSequence
{
    public override double Utility()
    {
		Characters parentOfType = FindParentOfType<Characters>(this);
		_character = parentOfType;
		double value = 0.0;
		if((_character.CharacterData as EnemyData).hate >0)
		{value = 0.6;}
		if(_character is scp173&&(_character as scp173).sightFrom.Count != 0)
        {
			value = 0;
        }
		return value;
    }

	public override void On_child_completed(bool result)
	{
		Characters parentOfType = FindParentOfType<Characters>(this);
		_character = parentOfType;
		if(!wait(_character.CharacterData.waitsec))
		{return;}
		
		if(_index_child_node>=this.GetChildCount())
		{
			if(result)
			{EmitSignal(SignalName.completed,succeed());return;}
			EmitSignal(SignalName.completed,faile());
			return;
		}
		//GD.Print("计时器：",_character._timer.TimeLeft);
		
		if(_character is scp173&&(_character as scp173).sightFrom.Count != 0)
        {
            EmitSignal(SignalName.completed,faile());
			return;
        }
		
		_index_child_node ++;
		Run_current_childnode();
		return;
		
	}
}
